package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class MainActivity3 extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        View call = findViewById(R.id.call);
        View message = findViewById(R.id.message);
        View other = findViewById(R.id.other);

        call.setOnClickListener(this);
        message.setOnClickListener(this);
        other.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        String num = "123456";
        switch (v.getId()) {
            case R.id.call:
                //打电话，设置意图
                intent.setAction(Intent.ACTION_DIAL);
                Uri uri = Uri.parse("tel:" + num);
                intent.setData(uri);
                startActivity(intent);
                break;
            case R.id.message:
                intent.setAction(Intent.ACTION_SENDTO);
                Uri uri2 = Uri.parse("smsto:" + num);
                intent.setData(uri2);
                startActivity(intent);
                break;

            case R.id.other:
                intent.setAction("清单文件里面intent-filter中的action的名字");
                intent.addCategory(Intent.CATEGORY_DEFAULT);
                startActivity(intent);
                break;
        }
    }



}